package com.ziyun.erp.web.modules.storeStockMaterialIo.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.storeStockMaterialIo.entity.StoreStockMaterialIoEntity;
import com.ziyun.erp.modules.storeStockMaterialIo.service.StoreStockMaterialIoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 门店库存交易明细表
 *
 * @author xueqz
 * @email 
 * @date 2019-01-23 08:56:38
 */
@RestController
@RequestMapping("storeStockMaterialIo/storestockmaterialio")
public class StoreStockMaterialIoController {
    @Autowired
    private StoreStockMaterialIoService storeStockMaterialIoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("storeStockMaterialIo:storestockmaterialio:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = storeStockMaterialIoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{ioId}")
    @RequiresPermissions("storeStockMaterialIo:storestockmaterialio:info")
    public R info(@PathVariable("ioId") Integer ioId){
        StoreStockMaterialIoEntity storeStockMaterialIo = storeStockMaterialIoService.selectById(ioId);

        return R.ok().put("storeStockMaterialIo", storeStockMaterialIo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("storeStockMaterialIo:storestockmaterialio:save")
    public R save(@RequestBody StoreStockMaterialIoEntity storeStockMaterialIo){
        storeStockMaterialIoService.insert(storeStockMaterialIo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("storeStockMaterialIo:storestockmaterialio:update")
    public R update(@RequestBody StoreStockMaterialIoEntity storeStockMaterialIo){
        ValidatorUtils.validateEntity(storeStockMaterialIo);
        storeStockMaterialIoService.updateAllColumnById(storeStockMaterialIo);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("storeStockMaterialIo:storestockmaterialio:delete")
    public R delete(@RequestBody Integer[] ioIds){
        storeStockMaterialIoService.deleteBatchIds(Arrays.asList(ioIds));

        return R.ok();
    }

}
